home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / m2 / ModGen.lha / ModGen / GetFile / InitGetC.asm < prev    next >
Assembly Source File  |  1995-04-23  |  8KB  |  288 lines

  1. ;
  2. ;   Program        :    InitGetC.s
  3. ;   Copyright        :    © Copyright 1992 Jaba Development
  4. ;   Author        :    Jan van den Baard
  5. ;   Creation Date   :    21-Jan-92
  6. ;   Current version :    1.1m
  7. ;   Translator        :    A68k
  8. ;
  9. ;   REVISION HISTORY
  10. ;
  11. ;   Date    Version      Comment
  12. ;   ---------    -------      ------------------------------------------
  13. ;   21-Jan-92    1.0      "GetFile" boopsi image.
  14. ;   17-Apr-95    1.1m      [Frank Lömker] boopsi image sizeable
  15. ;
  16.  
  17. omNEW        EQU    $101
  18. imDraw        EQU    $202
  19. idsSelected    EQU    1
  20.  
  21. MakeClass    EQU    -678
  22. SetAPen        EQU    -342
  23. RectFill    EQU    -306
  24. Move        EQU    -240
  25. PolyDraw    EQU    -336
  26. DrawBevelBoxA    EQU    -120
  27. GetTagData    EQU    -36
  28.  
  29. h_Entry        EQU    8    ; Hook
  30.  
  31. AreaPtrn    EQU    8    ; RastPort
  32. AreaPtSz    EQU    29
  33.  
  34. cl_Super    EQU    24    ; IClass
  35. cl_UserData    EQU    36
  36.  
  37. Width        EQU    4    ; Image
  38. Height        EQU    6
  39. ImageData    EQU    10
  40.  
  41. dri_Pens    EQU    4    ; DrawInfo
  42.  
  43. ops_AttrList    EQU    4    ; opSet
  44.  
  45. imp_RPort    EQU    4    ; impDraw
  46. imp_OffsetX    EQU    8
  47. imp_OffsetY    EQU    10
  48. imp_State    EQU    12
  49. imp_DrInfo    EQU    16
  50.  
  51. TAG_USER    EQU    $80000000
  52. TAG_DONE    EQU    0
  53. GT_TagBase    EQU    TAG_USER+$80000
  54. GT_VisualInfo    EQU    GT_TagBase+52
  55. GTBB_Recessed    EQU    GT_TagBase+51
  56. IMAGE_ATTRIBUTES EQU    (TAG_USER+$20000)
  57. IA_Width    EQU    (IMAGE_ATTRIBUTES+$0003)
  58. IA_Height    EQU    (IMAGE_ATTRIBUTES+$0004)
  59. TEXTPEN        EQU    2
  60. FILLPEN        EQU    5
  61. FILLTEXTPEN    EQU    6
  62. BACKGROUNDPEN    EQU    7
  63.  
  64.         SECTION "InitGet",CODE
  65.  
  66.         NEAR
  67.  
  68.         XREF    _IntuitionBase
  69.         XREF    _GfxBase
  70.         XREF    _UtilityBase
  71.         XREF    _GadToolsBase
  72.  
  73.         XDEF    _InitGet
  74.  
  75. ; --- Initialize our private class. It set's up a class
  76. ; --- with "imageclass" as superclass.
  77.  
  78. _InitGet:    MOVEM.L        A2/A6,-(SP)        ; save registers
  79.         MOVE.L        _IntuitionBase(A4),A6
  80.         SUBA.L        A0,A0        ; class ID
  81.         LEA.L        IClassName,A1    ; points to "imageclass"
  82.         SUBA.L        A2,A2        ; no superclass pointer
  83.         MOVEQ        #0,D0        ; no instance data
  84.         MOVEQ        #0,D1        ; no flags
  85.         JSR        MakeClass(A6)    ; make the class
  86.         MOVE.L        D0,A0        ; put class in a0
  87.         TST.L        D0
  88.         BEQ.S        noClass        ; failed!!!
  89.         LEA.L        dispatchGet(PC),A1    ; pointer to dispatcher
  90.         MOVE.L        A1,h_Entry(A0)    ; set our dispatcher
  91.         MOVE.L        A4,cl_UserData(A0)
  92. noClass:    MOVEM.L        (SP)+,A2/A6        ; restore registers
  93.         RTS
  94.  
  95. dispatchGet:    MOVEM.L        D2-D7/A2-A6,-(SP)    ; save registers
  96.         MOVE.L        A0,A5        ; class to a5
  97.         MOVE.L        cl_UserData(A5),A4
  98.         MOVE.L        A1,A3        ; msg to a3
  99.  
  100.         CMPI.L        #omNEW,(A3)        ; user want a new object ?
  101.         BNE.S        noNew        ; no!
  102.  
  103.         MOVE.L        A5,A0        ; class to a0
  104.         MOVE.L        A3,A1        ; msg to a1
  105.         BSR        callSuper        ; call the superclass
  106.         MOVE.L        D0,A2        ; put object in a2
  107.         BEQ.S        newError        ; failed!!!
  108.  
  109.         MOVE.L        _UtilityBase(A4),A6
  110.         MOVE.L        #GT_VisualInfo,D0    ; tag VisualInfo
  111.         MOVEQ        #0,D1        ; default = NULL
  112.         MOVE.L        ops_AttrList(A3),A0 ; tags to a0
  113.         JSR        GetTagData(A6)
  114.         MOVE.L        D0,ImageData(A2)    ; set visualInfo
  115.         BEQ.S        newError        ; tag found ?
  116.  
  117.         MOVE.L        #IA_Width,D0    ; tag Width
  118.         MOVEQ        #20,D1        ; default = 20
  119.         MOVE.L        ops_AttrList(A3),A0 ; tags to a0
  120.         JSR        GetTagData(A6)
  121.         MOVE.W        D0,Width(A2)    ; set width
  122.  
  123.         MOVE.L        #IA_Height,D0    ; tag Height
  124.         MOVEQ        #14,D1        ; default = 14
  125.         MOVE.L        ops_AttrList(A3),A0 ; tags to a0
  126.         JSR        GetTagData(A6)
  127.         MOVE.W        D0,Height(A2)    ; set width
  128.  
  129.         MOVE.L        A2,D0        ; return Object
  130.         BRA        Done
  131. newError:    MOVEQ        #0,D0        ; 0 for error
  132.         BRA        Done
  133.  
  134. noNew:        CMPI.L        #imDraw,(A3)    ; must we draw    ?
  135.         BNE        default        ; no!
  136.  
  137. draw:        MOVEQ        #0,D4        ; left = 0
  138.         MOVEQ        #0,D5        ; top = 0
  139.         MOVEQ        #0,D6        ; width = 0
  140.         MOVEQ        #0,D7        ; height = 0
  141.  
  142.         MOVE.W        imp_OffsetX(A3),D4    ; left = x offset
  143.         MOVE.W        imp_OffsetY(A3),D5    ; top = y offset
  144.         MOVE.W        Width(A2),D6    ; width
  145.         MOVE.W        Height(A2),D7    ; height
  146.  
  147.         MOVE.L        _GfxBase(A4),A6
  148.         MOVE.L        imp_RPort(A3),A5    ; rport to a5
  149.         MOVE.L        ImageData(A2),-(SP)    ; visualinfo on stack
  150.  
  151.         MOVE.L        imp_DrInfo(A3),A2    ; drawinfo to a2
  152.         MOVE.L        dri_Pens(A2),A2    ; drawinfo pens to a2
  153.  
  154.         CLR.L        AreaPtrn(A5)    ; clear area pattern
  155.         CLR.B        AreaPtSz(A5)
  156.  
  157.         MOVE.L        A5,A1        ; rport to a1
  158.  
  159.         CMPI.L        #idsSelected,imp_State(A3) ; draw selected ?
  160.         BNE.S        noSel        ; no!
  161.         MOVE.W        FILLPEN*2(A2),D0    ; FILLPEN color
  162.         BRA.S        penDone
  163. noSel:        MOVE.W        BACKGROUNDPEN*2(A2),D0 ; BACKGROUNDPEN color
  164. penDone:    JSR        SetAPen(A6)        ; set the pen
  165.  
  166.         MOVE.L        A5,A1        ; rport to a1
  167.         MOVE.W        D4,D0        ; left to d0
  168.         MOVE.W        D5,D1        ; top to d1
  169.         MOVE.W        D4,D2
  170.         ADD.W        D6,D2
  171.         SUBQ.W        #1,D2        ; left + width - 1 to d2
  172.         MOVE.W        D5,D3
  173.         ADD.W        D7,D3
  174.         SUBQ.W        #1,D3        ; top + height - 1 to d3
  175.         JSR        RectFill(A6)
  176.  
  177.         MOVE.L        _GadToolsBase(A4),A6
  178.         MOVE.L        A5,A0        ; rport to a0
  179.         MOVE.L        D4,D0        ; left to d0
  180.         MOVE.L        D5,D1        ; top to d1
  181.         MOVE.L        D6,D2        ; width to d2
  182.         MOVE.L        D7,D3        ; height to d3
  183.         PEA        TAG_DONE
  184.         MOVE.L        4(SP),-(SP)        ; VisualInfo
  185.         PEA        GT_VisualInfo
  186.         CMPI.L        #idsSelected,imp_State(A3) ; draw recessed ?
  187.         BNE.S        normal
  188.         PEA        1            ; recessed
  189.         PEA        GTBB_Recessed
  190. normal:        MOVE.L        SP,A1
  191.         JSR        DrawBevelBoxA(A6)    ; draw the bevel box
  192.         LEA.L        16(SP),SP        ; restore stack ptr
  193.         CMPI.L        #idsSelected,imp_State(A3)
  194.         BNE.S        ok
  195.         ADDQ.W        #8,SP        ; restore stack a little more
  196. ok:
  197.         MOVE.L        _GfxBase(A4),A6
  198.         MOVE.L        A5,A1        ; rport to a1
  199.         CMPI.L        #idsSelected,imp_State(A3) ; selected text pen?
  200.         BNE.S        noFPen
  201.         MOVE.W        FILLTEXTPEN*2(A2),D0 ; FILLTEXTPEN color
  202.         BRA.S        setPen
  203. noFPen:        MOVE.W        TEXTPEN*2(A2),D0    ; TEXTPEN color
  204. setPen:        JSR        SetAPen(A6)        ; set the pen
  205.  
  206.         LEA.L        -52(SP),SP        ; create stack space
  207.         MOVEQ        #12,D0        ; 13 XY pairs
  208.         LEA.L        PolyArray(PC),A1    ; pointer to XY array in a1
  209.         LEA.L        (SP),A0        ; stack ptr to a0
  210. loopCnt:    MOVEQ        #0,D2
  211.         MOVEQ        #0,D1
  212.         MOVE.W        (A1)+,D1        ; X to d0
  213.         CMP.W        #(1+4),D1        ; 2 lines side by side ?
  214.         BNE.S        notx
  215.         SUBQ.W        #1,D1        ; yes
  216.         MOVEQ        #1,D2
  217. notx:        MULU        D6,D1
  218.         DIVU        #20,D1
  219.         ADD.W        D4,D1        ; X*width div default + left
  220.         ADD.W        D2,D1
  221.         MOVE.W        D1,(A0)+        ; X to (a0)+
  222.         MOVEQ        #0,D2
  223.         MOVEQ        #0,D1
  224.         MOVE.W        (A1)+,D1        ; Y to d0
  225.         CMP.W        #(-5+10),D1        ; 2 lines side by side ?
  226.         BNE.S        noty
  227.         SUBQ.W        #1,D1        ; yes
  228.         MOVEQ        #1,D2
  229. noty:        MULU        D7,D1
  230.         DIVU        #14,D1
  231.         ADD.W        D5,D1        ; Y*height div default + top
  232.         ADD.W        D2,D1
  233.         MOVE.W        D1,(A0)+        ; Y to (a0)+
  234.         DBRA        D0,loopCnt
  235.  
  236.         MOVE.L        A5,A1        ; rport to a1
  237.         MOVEQ        #4,D0
  238.         MULU        D6,D0
  239.         DIVU        #20,D0        ; offset*width div default
  240.         ADD.W        D4,D0        ; left+offset
  241.         MOVEQ        #10,D1
  242.         MULU        D7,D1
  243.         DIVU        #14,D1        ; offset*height div default
  244.         ADD.W        D5,D1        ; top+offset
  245.         JSR        Move(A6)        ; move to this point
  246.  
  247.         MOVE.L        A5,A1        ; rport to a1
  248.         MOVE.L        SP,A0        ; array pointer in a0
  249.         MOVEQ        #13,D0        ; 13 XY pairs
  250.         JSR        PolyDraw(A6)    ; draw the lines
  251.  
  252.         LEA.L        52(SP),SP        ; restore original stackptr *)
  253.         MOVEQ        #1,D0        ; return TRUE
  254.         BRA.S        Done
  255.  
  256. default:    MOVE.L        A5,A0        ; class to a0
  257.         MOVE.L        A3,A1        ; msg to a1
  258.         BSR        callSuper        ; call superclass
  259. Done:        MOVEM.L        (SP)+,D2-D7/A2-A6    ; restore registers
  260.         RTS
  261.  
  262. ;  --- This routine call's this class it's super class.
  263. ;  --- First it get's the class it's super class in a0.
  264. ;  --- Then it pushes "ourRet" on the stack which will be
  265. ;  --- the return address of the superclass dispatcher.
  266. ;  --- Then it pushes the lowlevel entry of the superclass
  267. ;  --- dispatcher on the stack and performs an rts which
  268. ;  --- causes a jump to the superclass dispatcher. When the
  269. ;   --- superclass dispatcher is done it will return to "ourRet".
  270.  
  271. callSuper:    MOVE.L        A2,-(SP)        ; save a2
  272.         MOVE.L        cl_Super(A0),A0    ; get superclass in a0
  273.         PEA        ourRet        ; push return address
  274.         MOVE.L        h_Entry(A0),-(SP)    ; push superclass dispatcher
  275.         RTS                ; jump to super dispatcher
  276. ourRet:        MOVE.L        (SP)+,A2        ; restore a2
  277.         RTS
  278.  
  279. IClassName:    DC.B        'imageclass',0    ; superclass ID
  280.         EVEN
  281.  
  282. PolyArray:    DC.W     0+4,-6+10,1+4,-6+10,1+4,0+10,11+4,0+10
  283.         DC.W    11+4,-6+10,9+4,-8+10,6+4,-8+10,4+4,-6+10
  284.         DC.W     1+4,-6+10,1+4,-5+10,5+4,-5+10,6+4,-4+10
  285.         DC.W    11+4,-4+10
  286.  
  287.         END
  288.